<template>
  <div class="audition188">
    <p>能。</p>
    <v-md-preview :text="text1" />
    <p>如果不想遍历到原型上的属性，可以用<span class="color">hasOwnProperty</span>过滤</p>
    <v-md-preview :text="text2" />
  </div>
</template>

<script>
const prefix = '``` js'
const suffix = '```'
export default {
  name: 'Audition188',
  data() {
    return {
      text1: `${prefix}
      Object.prototype.a = 1
      var obj = {
        name: 'dilireba',
        age: 18
      }
      for(var k in obj) {
        console.log(k) // name age a
      }
      \n${suffix}`,
      text2: `${prefix}
      for(var k in obj) {
        if(obj.hasOwnProperty(k)) {
          console.log(k) // name age
        }
      }
      \n${suffix}`,
    }
  }
}
</script>

<style>

</style>